import { createSlice } from "@reduxjs/toolkit"

type ProviderState = {
  loading?: boolean
  error?: string
  provider?: User
}

type licenseState = {
  expire_date: string
  provider: string
  license_type: string
  license_number: string
  state: string
}

type User = {
  id?: string
  avatar?: string
  first_name?: string
  last_name?: string
  is_kiosk?: boolean
  is_welcome_board?: boolean
  is_active?: boolean
  status?: string
  date_of_birth?: string
  practice?: string
  middle_name?: string
  suffix?: string
  phone_number?: string
  npi?: string
  npi_two?: string
  caqh?: string
  taxonomy?: string
  email?: string
  cancelation_balance?: string
  created_at?: string
  ethera_credit?: string
  promo_credit?: string
  provider_license?: licenseState[]
}
const initialState: ProviderState = {
  provider: null,
  loading: false,
  error: "",
}

const providerSlice = createSlice({
  name: "provider",
  initialState,
  reducers: {
    setProviderInfo: (state, action) => {
      state.provider = action?.payload
    },
  },
})

export default providerSlice.reducer
export const { setProviderInfo } = providerSlice.actions
